<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>PLMSSO</title>
</head>
<body onload="loadJS()">

</body>
<script type="text/javascript">
	function loadJS(){
		var loginName = '${currentUser}';
		// IE8 没有console对象，请勿使用！！！
		userlogin(loginName);
	}

/*  PLM系统提供js   start */
function EditEnv(name) {
    var objShell = new ActiveXObject("wscript.shell");
    var EnvironmentSet = objShell.Environment("user");
    EnvironmentSet("TCUSER") = name;
    objShell = null;
}
function GetSystemEnv(name)
{
    var objShell = new ActiveXObject("wscript.shell");
    var EnvironmentSet = objShell.Environment("system");
    return EnvironmentSet(name);
}
function GetUserEnv(name) {
    var objShell = new ActiveXObject("wscript.shell");
    var EnvironmentSet = objShell.Environment("user");
    return EnvironmentSet(name);
}
function Run(path) {
    var objShell = new ActiveXObject("wscript.shell");
    objShell.Run(path, 0, true);
    objShell = null;
}
function writeFile(filename, filecontent) {
    var fso, f, s;
    fso = new ActiveXObject("Scripting.FileSystemObject");
    fso.createtextfile(filename,true);
    f = fso.OpenTextFile(filename, 8, true);
    f.WriteLine(filecontent);
    f.Close();
}
function closeWebPage() {
    if (navigator.userAgent.indexOf("MSIE") > 0) {//close IE  
        if (navigator.userAgent.indexOf("MSIE 6.0") > 0) {
            window.opener = null;
            window.close();
        } else {
            window.open('', '_top');
            window.top.close();
        }
    }
    else if (navigator.userAgent.indexOf("Firefox") > 0) {//close firefox  
        window.location.href = 'about:blank ';
    } else {//close chrome;It is effective when it is only one.  
        window.opener = null;
        window.open('', '_self');
        window.close();
    }
}

function userlogin(userid)
{
	var bat_path = "D:\\Siemens\\Teamcenter\\OTW11\\rac\\portal.bat";
	var fso=new ActiveXObject("Scripting.FileSystemObject");
	if(!fso.FileExists(bat_path)){
		alert("本机没有安装Teamcenter客户端!");
        closeWebPage();
        return;
	}
    Run(bat_path + " -Duserid=" + userid);
	closeWebPage();
}
/*   PLM系统提供js   end   */
 
</script>
</html>